package com.wmuj.service.impl;

import com.wmuj.mapper.EmpLogMapper;
import com.wmuj.pojo.EmpLog;
import com.wmuj.service.EmpLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class EmpLogServiceImpl implements EmpLogService {

  @Autowired private EmpLogMapper empLogMapper;

  // 1.默认的是：如果当前事务存在，则加入，否则新建一个事务
  // 2.propagation = Propagation .REQUIRES_NEW 是新建一个事务 需要在新的事务里
  @Transactional(propagation = Propagation.REQUIRES_NEW)
  @Override
  public void insertLog(EmpLog empLog) {

    empLogMapper.insert(empLog);
  }
}
